<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试报告</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 2rem;
            color: #2d3748;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .header {
            background: white;
            border-radius: 16px;
            padding: 2rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            font-size: 1.75rem;
            font-weight: 600;
            color: #1a202c;
            margin-bottom: 0.5rem;
        }

        .timestamp {
            color: #718096;
            font-size: 0.875rem;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1rem;
            margin-bottom: 1.5rem;
        }

        .stat-card {
            background: white;
            border-radius: 12px;
            padding: 1.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            transition: transform 0.2s, box-shadow 0.2s;
        }

        .stat-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
        }

        .stat-label {
            font-size: 0.875rem;
            color: #718096;
            margin-bottom: 0.5rem;
            font-weight: 500;
        }

        .stat-value {
            font-size: 2rem;
            font-weight: 700;
        }

        .stat-card.total .stat-value { color: #667eea; }
        .stat-card.passed .stat-value { color: #48bb78; }
        .stat-card.failed .stat-value { color: #f56565; }
        .stat-card.skipped .stat-value { color: #ed8936; }

        .chart-section {
            background: white;
            border-radius: 16px;
            padding: 2rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
        }

        .chart-wrapper {
            max-width: 400px;
            margin: 0 auto;
        }

        .results-section {
            background: white;
            border-radius: 16px;
            padding: 2rem;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
            margin-bottom: 1.5rem;
        }

        .section-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: #1a202c;
            margin-bottom: 1.5rem;
        }

        .suite-section {
            margin-bottom: 2rem;
        }

        .suite-title {
            font-size: 1.1rem;
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid #e2e8f0;
        }

        .test-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            font-size: 0.875rem;
            margin-bottom: 1.5rem;
        }

        .test-table thead {
            background: #f7fafc;
        }

        .test-table th {
            text-align: left;
            padding: 0.75rem 1rem;
            font-weight: 600;
            color: #4a5568;
            border-bottom: 2px solid #e2e8f0;
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.025em;
        }

        .test-table td {
            padding: 0.875rem 1rem;
            border-bottom: 1px solid #f1f5f9;
        }

        .test-table tbody tr:hover {
            background: #f8fafc;
        }

        .status-badge {
            display: inline-flex;
            align-items: center;
            gap: 0.375rem;
            padding: 0.25rem 0.75rem;
            border-radius: 9999px;
            font-size: 0.75rem;
            font-weight: 600;
        }

        .status-badge.pass {
            background: #c6f6d5;
            color: #22543d;
        }

        .status-badge.fail {
            background: #fed7d7;
            color: #742a2a;
        }

        .status-badge.skip {
            background: #feebc8;
            color: #7c2d12;
        }

        .status-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            display: inline-block;
        }

        .status-badge.pass .status-dot { background: #38a169; }
        .status-badge.fail .status-dot { background: #e53e3e; }
        .status-badge.skip .status-dot { background: #dd6b20; }

        .error-toggle {
            color: #667eea;
            cursor: pointer;
            font-weight: 500;
            text-decoration: none;
            transition: color 0.2s;
        }

        .error-toggle:hover {
            color: #5a67d8;
            text-decoration: underline;
        }

        .error-details {
            margin-top: 0.5rem;
            padding: 1rem;
            background: #fff5f5;
            border-left: 3px solid #fc8181;
            border-radius: 4px;
            font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
            font-size: 0.75rem;
            color: #742a2a;
            white-space: pre-wrap;
            word-break: break-word;
            max-height: 200px;
            overflow-y: auto;
        }

        .footer {
            text-align: center;
            color: white;
            font-size: 0.875rem;
            margin-top: 2rem;
            opacity: 0.8;
        }

        @media (max-width: 768px) {
            body {
                padding: 1rem;
            }

            .header h1 {
                font-size: 1.5rem;
            }

            .stat-value {
                font-size: 1.5rem;
            }

            .test-table {
                font-size: 0.75rem;
            }

            .test-table th,
            .test-table td {
                padding: 0.5rem;
            }
        }

    </style>
</head>
<body>
<div class="container">
    <div class="header">
        <h1>测试报告</h1>
        <div class="timestamp">${generationTime}</div>
    </div>

    <div class="stats-grid">
        <div class="stat-card total">
            <div class="stat-label">总用例数</div>
            <div class="stat-value">${totalTests}</div>
        </div>
        <div class="stat-card passed">
            <div class="stat-label">通过</div>
            <div class="stat-value">${totalPassed}</div>
        </div>
        <div class="stat-card failed">
            <div class="stat-label">失败</div>
            <div class="stat-value">${totalFailed}</div>
        </div>
        <div class="stat-card skipped">
            <div class="stat-label">跳过</div>
            <div class="stat-value">${totalSkipped}</div>
        </div>
    </div>

    <div class="chart-section">
        <div class="chart-wrapper">
            <canvas id="summaryChart"></canvas>
        </div>
    </div>

    <div class="results-section">
        <h2 class="section-title">测试详情</h2>
        <#list suites as suite>
            <div class="suite-section">
                <div class="suite-title">${suite.name}</div>
                <#list suite.testClasses as testClass>
                    <table class="test-table">
                        <thead>
                        <tr>
                            <th>测试用例</th>
                            <th>状态</th>
                            <th>开始时间</th>
                            <th>耗时</th>
                            <th>详情</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list testClass.results as result>
                            <tr>
                                <td>${result.methodName}</td>
                                <td>
                                    <span class="status-badge ${result.status}">
                                        <span class="status-dot"></span>
                                        ${result.statusText}
                                    </span>
                                </td>
                                <td>${result.startTime}</td>
                                <td>${result.duration}</td>
                                <td>
                                    <#if result.exceptionMessage?? && result.exceptionMessage != "">
                                        <a class="error-toggle" onclick="toggleError(this)">查看错误</a>
                                        <div class="error-details" style="display:none;">${result.exceptionMessage}</div>
                                    <#else>
                                        <span style="color: #a0aec0;">-</span>
                                    </#if>
                                </td>
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                </#list>
            </div>
        </#list>
    </div>

    <div class="footer">Laker AutoTest Framework &copy; 2025</div>
</div>

<script>
    const ctx = document.getElementById('summaryChart').getContext('2d');
    new Chart(ctx, {
        type: 'doughnut',
        data: {
            labels: ['通过', '失败', '跳过'],
            datasets: [{
                data: [${totalPassed}, ${totalFailed}, ${totalSkipped}],
                backgroundColor: ['#48bb78', '#f56565', '#ed8936'],
                borderWidth: 0,
                cutout: '70%'
            }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: true,
            plugins: {
                legend: {
                    position: 'bottom',
                    labels: {
                        padding: 20,
                        font: { size: 14 },
                        usePointStyle: true,
                        pointStyle: 'circle'
                    }
                }
            }
        }
    });

    function toggleError(link) {
        const errorDiv = link.nextElementSibling;
        if (errorDiv.style.display === 'none') {
            errorDiv.style.display = 'block';
            link.textContent = '隐藏错误';
        } else {
            errorDiv.style.display = 'none';
            link.textContent = '查看错误';
        }
    }
</script>
</body>
</html>